package com.ls.markt.service.admin.impl;

import com.ls.markt.dao.admin.TrophyMapper;
import com.ls.markt.model.admin.Trophy;
import com.ls.markt.repository.admin.TrophyRepository;
import com.ls.markt.service.admin.TrophyService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class TrophyServiceImpl implements TrophyService {

    @Resource
    private TrophyMapper mapper;

    @Resource
    private TrophyRepository trophyRepository;

    @Override
    public Page<Trophy> listTrophys(PageRequest pageRequest) {
        return trophyRepository.findAll(pageRequest);
    }

    @Override
    public void saveTrophy(Trophy trophy) {
        trophyRepository.save(trophy);
    }

//    @Override
//    public void updateTrophy(Trophy trophy) {
//        mapper.update(trophy);
//    }

    @Override
    public void removeTrophy(Long id) {
        trophyRepository.deleteById(id);
    }

    @Override
    public Trophy getTrophyById(Long id) {
        return trophyRepository.getOne(id);
    }

    @Override
    public List<Map<String,Object>> getTrophyByClub(Long clubId) {
        return mapper.getTrophyByClub(clubId);
    }

    @Override
    public List<Trophy> listTrophyByEnum(Long trophyId) {
        return mapper.findByTrophyId(trophyId);
    }
}
